<include file="nav:header"/>
<div class="container-fluid">
    <div class="row">
        <include file="Left:left-Common"/>
        <div class="col-md-10 right">
            <div class="page-header" style="margin-right: 15px">
                <h3>{$page_title}</h3>
            </div>
            <div class="index_top">
                <div style="margin-left: 50px" class="btn-group pull-left " role="group" aria-label="Large button group">
                    <a href="{:U('Admin/index')}" type="button" class="btn btn-primary">بارلىق ئابونت</a>
                    <a href="{:U('Admin/add')}"  type="button" class="btn btn-primary">ئابونت قوشۇش</a>
                </div>
            </div>
            <br>
            <table class="table table-bordered">
                <thead>
                <tr class="info">
                    <td width="30">ID</td>
                    <td style="text-align: center">ئىسمى</td>
                    <td style="text-align: center">ئېلىخەت</td>
                    <td style="text-align: center">قېتىلغان ۋاقىت</td>
                    <td style="text-align: center">ھالىتى</td>
                    <td style="text-align: center">مەشغۇلات</td>
                </tr>
                </thead>
                <tbody>
                <foreach name="users" item="u">
                    <tr class="classifys active">
                        <td>{$u['id']}</td>
                        <td style="text-align: center">{$u['username']}</td>
                        <td class="text-left" style="direction: ltr;text-align: center">{$u['email']}</td>
                        <td class="text-left" style="direction: ltr;text-align: center">{$u['lasttime'] | date="Y-m-d H:i",###}</td>
                        <td style="text-align: center">
                            <if condition="$u['status'] eq 1 and $u.username neq $sesion">
                                <span style="margin-top: 6px;display: inline-block;"  onclick="_status(this,0,{$u['id']})"  class="btn btn-success btn-xs kaiguan">قوزغىتىلدى</span>
                                <elseif condition="$u.username eq $sesion"/>
                                <span title="بۇنىڭ بىلەن ھەپىلەشمىسىلە" style="margin-top: 6px;display: inline-block;"   class="btn btn-success btn-xs kaiguan"> قوزغىتىلدى (ئۆزىڭىز)</span>
                                <else/>
                                <span style="margin-top: 6px;display: inline-block;" onclick="_status(this,1,{$u['id']})" class="btn btn-danger btn-xs kaiguan">قوزغىتىلمىدى</span>
                            </if>
                        </td>
                        <td style="text-align: center">
                            <a href="{:U('Admin/edit')}?id={$u.id}" class="label label-success">تەھرىرلەش</a>
                            <if condition="$u.username eq $sesion">
                                <a href="javascript:del({$u['id']});" class="btn btn-danger btn-xs disabled">ئۆچۈرۈش</a>
                                <else/>
                                <a href="javascript:del({$u['id']});" class="label label-danger">ئۆچۈرۈش</a>
                            </if>
                        </td>
                    </tr>
                </foreach>
                </tbody>
            </table>
        </div>
    </div>
</div>
<script type="text/javascript">
    //删除分类
    function del(id) {
        layer.confirm('بۇ ئۇچۇرنى راستىنلا ئۆچۈرەمسىز ؟', {
            btn: ['ھەئە','ياق'] ,//按钮,
            title:"سېستىما ئەسكەرتىشى"
        }, function(){
            $.ajax({
                type:"post",
                url:"{:U('Admin/del')}",
                dataType:"json",
                data:{"id":id},
                success:function (phpdata) {
                    if(phpdata.status==1){
                        layer.alert(phpdata.message, {
                            title:"سېستىما ئەسكەرتىشى",
                            btn:"بىلدىم",
                            icon: 6,
                            skin: 'layer-ext-moon',
                            time:800
                        });
                        window.location=location;
                    }else{
                        layer.alert(phpdata.message, {
                            title:"سېستىما ئەسكەرتىشى",
                            btn:"بىلدىم",
                            icon: 5,
                            skin: 'layer-ext-moon',
                            time:1000
                        });
                    }
                }
            })
        });

    }
    //分类状态
    function _status(obj,status,id) {
        if(status=='0'){
            $(obj).removeClass("btn-success");
            $(obj).addClass("btn-danger");
            $(obj).text("قوزغىتىلمىدى")
        }else {
            $(obj).removeClass("btn-danger");
            $(obj).addClass("btn-success");
            $(obj).text("قوزغىتىلدى")
        }
        $.ajax({
            type:"post",
            url:"{:U('Admin/sortStatus')}",
            dataType:"json",
            data:{"id":id,"status":status},
            success:function (phpdata) {
                if(phpdata.status==1){
                    layer.alert(phpdata.content, {
                        title:"سېستىما ئەسكەرتىشى",
                        btn:"بىلدىم",
                        icon: 6,
                        skin: 'layer-ext-moon',
                        time:400
                    });
                    window.location=location;
                }else{
                    layer.alert(phpdata.content, {
                        title:"سېستىما ئەسكەرتىشى",
                        btn:"بىلدىم",
                        icon: 5,
                        skin: 'layer-ext-moon',
                        time:1000
                    });
                }
            }
        })
    }
    $(function () {
        $('.classifys').hover(function () {
            $(this).addClass('info');
        },function () {
            $(".classifys").removeClass('info');
        })
    })
</script>
<include file="nav:footer"/>